package com.youmu.shop.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.io.IOUtils;

public class ConfigUtil {

    private static String LOCAL_DOMAIN;
	/**
	 * 图片服务器地址
	 */
	private static String IMG_HOST;

	private static String IMG_UPLOAD_PATH;

	/**
	 * alidayu
	 */

	private static String ALIDAYU_URL;

	private static String ALIDAYU_APPKEY;

	private static String ALIDAYU_SECRET;

	/*
	 * sms
	 */
	private static String SMS_SIGN;

	private static String SMS_TYPE;

	/**
	 * 模板
	 */

	private static String SMS_TEMPLATE_CODE_PROMPT;

	/**
	 * vms
	 */
	private static String VMS_CALLED_SHOW_NUMBER;
	private static String VMS_TEMPLATE_CODE_PROMPT;
	/**
	 * mail
	 */
	private static String MAIL_SERVER_HOST;
	private static String MAIL_SERVER_PORT;
	private static String MAIL_FROM_ADDRESS;
	private static String SERVER_USER_NAME;
	private static String SERVER_PASS_WORD;
	private static String SERVER_VALIDATE;
	private static String MAIL_SUBJECT;
	private static String MAIL_CONTENT;

	private static int RESEND_COUNT;

	/**
	 * 微信
	 */
	private static String WEIXIN_APP_ID;
	private static String WEIXIN_PARTNER_ID;
	private static String WEIXIN_NOTIFY_URL;
	private static String WEIXIN_KEY;
    private static String WEIXIN_APP_SECRE;
    private static String WEIXIN_AUTH_URL; 
    private static String WEIXIN_AUTH_REDIRECT_URI; 
    private static String WEIXIN_RESPONSE_TYPE; 
    private static String WEIXIN_SCOPE;  
    private static String WECHAT_REDIRECT;  
    private static String WEIXIN_GET_ACCESS_TOKEN_URL;
    private static String WEIXIN_GET_USER_INFO_URL;
    private static String WEIXIN_AUTOMATIC_SEND_MESSAGE_URL;
	private static String WEIXIN_A_TOKEN;
	private static String WEIXIN_BASIC_GET_ACCESS_TOKEN;
	/**
	 * 快递鸟
	 */
	private static String KDNIAO_PARTNER_ID;
	private static String KDNIAO_KEY;
	
	/**
     * 管理系统后台提供的接口
     */
    private static String CALCULATE_FREIGHT_URL;
    private static String CALCULATE_ZONE_URL;
    
    /**
     * 百度地图API
     */
    private static String BAIDU_MAP_ADDRESS_TO_LONGITUDE_AND_LATITUDE;
    private static String BAIDU_MAP_AK;
	

	static {
		Properties prop = new Properties();
		InputStream in = ConfigUtil.class.getResourceAsStream("/config.properties");
		try {
			prop.load(in);
			LOCAL_DOMAIN = prop.getProperty("local_domain").trim();
			IMG_HOST = prop.getProperty("img_host").trim();
			IMG_UPLOAD_PATH = prop.getProperty("img_upload_path").trim();
			ALIDAYU_URL = prop.getProperty("alidayu_url").trim();
			ALIDAYU_APPKEY = prop.getProperty("alidayu_appkey").trim();
			ALIDAYU_SECRET = prop.getProperty("alidayu_secret").trim();
			SMS_TYPE = prop.getProperty("sms_type").trim();
			SMS_SIGN = new String(prop.getProperty("sms_sign").getBytes("ISO-8859-1"), "utf-8").trim();
			SMS_TEMPLATE_CODE_PROMPT = prop.getProperty("sms_template_code_prompt").trim();
			VMS_CALLED_SHOW_NUMBER = prop.getProperty("vms_called_Show_number").trim();
			VMS_TEMPLATE_CODE_PROMPT = prop.getProperty("vms_template_code_prompt").trim();
			MAIL_SERVER_HOST = prop.getProperty("mail_server_host").trim();
			MAIL_SERVER_PORT = prop.getProperty("mail_server_port").trim();
			MAIL_FROM_ADDRESS = prop.getProperty("mail_from_address").trim();
			SERVER_USER_NAME = prop.getProperty("server_user_name").trim();
			SERVER_PASS_WORD = prop.getProperty("server_pass_word").trim();
			SERVER_VALIDATE = prop.getProperty("server_validate").trim();
			MAIL_SUBJECT = new String(prop.getProperty("mail_subject").getBytes("ISO-8859-1"), "utf-8").trim();
			MAIL_CONTENT = new String(prop.getProperty("mail_content").getBytes("ISO-8859-1"), "utf-8").trim();
			RESEND_COUNT = Integer.valueOf(prop.getProperty("resend_count").trim());
			WEIXIN_APP_ID = prop.getProperty("weixin_app_id").trim();
			WEIXIN_PARTNER_ID = prop.getProperty("weixin_partner_id").trim();
			WEIXIN_NOTIFY_URL = prop.getProperty("weixin_notify_url").trim();
			WEIXIN_KEY = prop.getProperty("weixin_key").trim();
			WEIXIN_APP_SECRE = prop.getProperty("weixin_app_secre").trim();
			WEIXIN_AUTH_URL = prop.getProperty("weixin_auth_url").trim();
			WEIXIN_AUTH_REDIRECT_URI = prop.getProperty("weixin_auth_redirect_uri").trim();
			WEIXIN_RESPONSE_TYPE = prop.getProperty("weixin_response_type").trim();
			WEIXIN_SCOPE = prop.getProperty("weixin_scope").trim();
			WECHAT_REDIRECT = prop.getProperty("wechat_redirect").trim();
			WEIXIN_GET_ACCESS_TOKEN_URL = prop.getProperty("weixin_get_access_token_url").trim();
			WEIXIN_GET_USER_INFO_URL = prop.getProperty("weixin_get_user_info_url").trim();
			KDNIAO_PARTNER_ID = prop.getProperty("kdniao_partner_id").trim();
			KDNIAO_KEY = prop.getProperty("kdniao_key").trim();
			CALCULATE_FREIGHT_URL = prop.getProperty("calculate_freight_url").trim();
			CALCULATE_ZONE_URL = prop.getProperty("calculate_zone_url").trim();
			WEIXIN_AUTOMATIC_SEND_MESSAGE_URL = prop.getProperty("weixin_automatic_send_message_url").trim();
			WEIXIN_A_TOKEN = prop.getProperty("weixin_a_token").trim();
			WEIXIN_BASIC_GET_ACCESS_TOKEN = prop.getProperty("weixin_basic_get_access_token").trim();
			BAIDU_MAP_ADDRESS_TO_LONGITUDE_AND_LATITUDE = prop.getProperty("baidu_map_address_to_longitude_and_latitude").trim();
			BAIDU_MAP_AK = prop.getProperty("baidu_map_ak").trim();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			IOUtils.closeQuietly(in);
		}
	}

	public static String getLocalDomain() {
		return LOCAL_DOMAIN;
	}
	
	public static String getImgHost() {
		return IMG_HOST;
	}

	public static String getImgUploadPath() {
		return IMG_UPLOAD_PATH;
	}

	public static String getAlidayuUrl() {
		return ALIDAYU_URL;
	}

	public static String getAlidayuAppkey() {
		return ALIDAYU_APPKEY;
	}

	public static String getAlidayuSecret() {
		return ALIDAYU_SECRET;
	}

	public static String getSMSType() {
		return SMS_TYPE;
	}

	public static String getSMSSign() {
		return SMS_SIGN;
	}

	public static String getSmsTemplateCodePrompt() {
		return SMS_TEMPLATE_CODE_PROMPT;
	}

	public static String getMailServerHost() {
		return MAIL_SERVER_HOST;
	}

	public static String getMailServerPort() {
		return MAIL_SERVER_PORT;
	}

	public static String getMailFromAddress() {
		return MAIL_FROM_ADDRESS;
	}

	public static String getServerUserName() {
		return SERVER_USER_NAME;
	}

	public static String getServerPassWord() {
		return SERVER_PASS_WORD;
	}

	public static String getServerValidate() {
		return SERVER_VALIDATE;
	}

	public static String getMailSubject() {
		return MAIL_SUBJECT;
	}

	public static String getMailContent() {
		return MAIL_CONTENT;
	}

	public static String getVmsCalledShowNumber() {
		return VMS_CALLED_SHOW_NUMBER;
	}

	public static String getVmsTemplateCodePrompt() {
		return VMS_TEMPLATE_CODE_PROMPT;
	}

	public static int getResendCount() {
		return RESEND_COUNT;
	}

	public static String getWeixinAppId() {
		return WEIXIN_APP_ID;
	}

	public static String getWeixinPartnerId() {
		return WEIXIN_PARTNER_ID;
	}

	public static String getWeixinNotifyUrl() {
		return WEIXIN_NOTIFY_URL;
	}

	public static String getWeixinKey() {
		return WEIXIN_KEY;
	}
	
	public static String getWeixinAuthUrl() {
		return WEIXIN_AUTH_URL;
	}
	
	public static String getWeixinAuthRedirectUrl() {
		return WEIXIN_AUTH_REDIRECT_URI;
	}
	
	public static String getWeixinResponseType() {
		return WEIXIN_RESPONSE_TYPE;
	}
	
	public static String getWeixinScope() {
		return WEIXIN_SCOPE;
	}

	public static String getWechatRedirect() {
		return WECHAT_REDIRECT;
	}
	
	public static String getWeixinAccessTokenUrl() {
		return WEIXIN_GET_ACCESS_TOKEN_URL;
	}
	
	public static String getWeixinUserInfoUrl() {
		return WEIXIN_GET_USER_INFO_URL;
	}
	
	public static String getKdniaoPartnerId() {
		return KDNIAO_PARTNER_ID;
	}

	public static String getKdniaoKey() {
		return KDNIAO_KEY;
	}

    public static String getCalculateFreightUrl() {
        return CALCULATE_FREIGHT_URL;
    }

    public static String getCalculateZoneUrl() {
        return CALCULATE_ZONE_URL;
    }

    public static String getWeixinAppSecre() {
        return WEIXIN_APP_SECRE;
    }
    
    public static String getWeixinAutomaticSendMessageUrl() {
    	return WEIXIN_AUTOMATIC_SEND_MESSAGE_URL;
    }

    public static String getWeiXinTokenKey(){
    	return WEIXIN_A_TOKEN;
    }

    public static String getWeixinBasicGetAccessToken() {
    	return WEIXIN_BASIC_GET_ACCESS_TOKEN;
    }
    
    public static String getBaiduMapAddressToLongitudeAndLatitude(){
    	return BAIDU_MAP_ADDRESS_TO_LONGITUDE_AND_LATITUDE;
    }
    
    public static String getBaiDuMapAk(){
    	return BAIDU_MAP_AK;
    }
    
}
